<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Pagination Control and ScrollingStyles - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/learning.paginator.control.html">Inglês (English)</a></li>
    <li><a href="../pt-br/learning.paginator.control.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="learning.paginator.simple.html">Simple Examples</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="learning.paginator.html">Getting Started with Zend_Paginator</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="learning.paginator.together.html">Putting it all Together</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="learning.paginator.control" class="section"><div class="info"><h1 class="title">Pagination Control and ScrollingStyles</h1></div>
    

    <p class="para">
        Rendering the items for a page on the screen has been a good start. In the code
        snippets in previous section we have also seen the
         <span class="methodname">setCurrentPageNumber()</span> method to set the active page number. The
        next step is to navigate through your pages. To do this, Paginator provides you with two
        important tools: the ability to render the Paginator with help of a View Partial, and
        support for so-called ScrollingStyles.
    </p>

    <p class="para">
        The View Partial is a small view script that renders the Pagination controls, such as
        buttons to go to the next or previous page. Which pagination controls are rendered depends
        on the contents of the view partial. Working with the view partial requires that you have
        set up <span class="classname">Zend_View</span>. To get started with the pagination control, create
        a new view script somewhere in your view scripts path. You can name it anything you want,
        but we&#039;ll call it &quot;controls.phtml&quot; in this text. The reference manual contains various
        examples of what might go in the view script. Here is one example.
    </p>

    <pre class="programlisting brush: php">
&lt;?php if ($this-&gt;pageCount): ?&gt;
&lt;!-- First page link --&gt;
&lt;?php if (isset($this-&gt;previous)): ?&gt;
  &lt;a href=&quot;&lt;?php echo $this-&gt;url(array(&#039;page&#039; =&gt; $this-&gt;first)); ?&gt;&quot;&gt;
    First
  &lt;/a&gt; |
&lt;?php else: ?&gt;
  &lt;span class=&quot;disabled&quot;&gt;First&lt;/span&gt; |
&lt;?php endif; ?&gt;

&lt;!-- Previous page link --&gt;
&lt;?php if (isset($this-&gt;previous)): ?&gt;
  &lt;a href=&quot;&lt;?php echo $this-&gt;url(array(&#039;page&#039; =&gt; $this-&gt;previous)); ?&gt;&quot;&gt;
    &amp;lt; Previous
  &lt;/a&gt; |
&lt;?php else: ?&gt;
  &lt;span class=&quot;disabled&quot;&gt;&amp;lt; Previous&lt;/span&gt; |
&lt;?php endif; ?&gt;

&lt;!-- Next page link --&gt;
&lt;?php if (isset($this-&gt;next)): ?&gt;
  &lt;a href=&quot;&lt;?php echo $this-&gt;url(array(&#039;page&#039; =&gt; $this-&gt;next)); ?&gt;&quot;&gt;
    Next &amp;gt;
  &lt;/a&gt; |
&lt;?php else: ?&gt;
  &lt;span class=&quot;disabled&quot;&gt;Next &amp;gt;&lt;/span&gt; |
&lt;?php endif; ?&gt;

&lt;!-- Last page link --&gt;
&lt;?php if (isset($this-&gt;next)): ?&gt;
  &lt;a href=&quot;&lt;?php echo $this-&gt;url(array(&#039;page&#039; =&gt; $this-&gt;last)); ?&gt;&quot;&gt;
    Last
  &lt;/a&gt;
&lt;?php else: ?&gt;
  &lt;span class=&quot;disabled&quot;&gt;Last&lt;/span&gt;
&lt;?php endif; ?&gt;

&lt;/div&gt;
&lt;?php endif; ?&gt;
</pre>


    <p class="para">
        The next step is to tell <span class="classname">Zend_Paginator</span> which view partial can be
        used to render the navigation controls. Put the following line in your application&#039;s
        bootstrap file.
    </p>

    <pre class="programlisting brush: php">
Zend_View_Helper_PaginationControl::setDefaultViewPartial(&#039;controls.phtml&#039;);
</pre>


    <p class="para">
        The last step is probably the easiest. Make sure you have assigned your Paginator object
        to the a script (NOT the &#039;controls.phtml&#039; script!). The only thing left to do is echo the
        Paginator in the view script. This will automatically render the Paginator using the
        PaginationControl view helper. In this next example, the Paginator object has been assigned
        to the &#039;paginator&#039; view variable. Don&#039;t worry if you don&#039;t fully get how it all works yet.
        The next section will feature a complete example.
    </p>

    <pre class="programlisting brush: php">
&lt;?php echo $this-&gt;paginator; ?&gt;
</pre>


    <p class="para">
        <span class="classname">Zend_Paginator</span>, together with the &#039;controls.phtml&#039; view script you
        wrote, makes sure your Paginator navigation is rendered properly. In order to decide
        which page numbers need to be displayed on screen, Paginator uses so-called ScrollingStyles.
        The default style is called &quot;Sliding&quot;, which is similar to the way Yahoo&#039;s search result
        navigation works. To mimick Google&#039;s ScrollingStyle, use the Elastic style.
        You can set a default ScrollingStyle with the static
         <span class="methodname">setDefaultScrollingStyle()</span> method, or you can specify a
        ScrollingStyle dynamically when rendering the Paginator in your view script. This requires
        manual invocation of the view helper in your view script.
    </p>

    <pre class="programlisting brush: php">
// $this-&gt;paginator is a Paginator object
&lt;?php echo $this-&gt;paginationControl($this-&gt;paginator, &#039;Elastic&#039;, &#039;controls.phtml&#039;); ?&gt;
</pre>


    <p class="para">
        For a list of all available ScrollingStyles, see the reference manual.
    </p>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="learning.paginator.simple.html">Simple Examples</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="learning.paginator.html">Getting Started with Zend_Paginator</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="learning.paginator.together.html">Putting it all Together</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="learning.html">Learning Zend Framework</a></li>
  <li class="header up"><a href="learning.paginator.html">Getting Started with Zend_Paginator</a></li>
  <li><a href="learning.paginator.intro.html">Introduction</a></li>
  <li><a href="learning.paginator.simple.html">Simple Examples</a></li>
  <li class="active"><a href="learning.paginator.control.html">Pagination Control and ScrollingStyles</a></li>
  <li><a href="learning.paginator.together.html">Putting it all Together</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>